class Index extends eui.Component implements eui.UIComponent {
	public clickLabel: eui.Label;
	public imgFilterArr: Array<any> = []; //滤镜arr
	public music: eui.Image;
	public reset: eui.Image;
	public endStart: eui.Group;
	public clickStart: eui.Image;
	public subNum = new Value<number>(1);	//定义可监听的数字

	public times: number = 500;
	public materialNum: number = 0;	//教材第几题监听
	public materialStepNum: number = 1;	//下一步监听


	public material: eui.Button;
	public game: eui.Button;
	public backing: eui.Button;
	public materialBj: eui.Group;

	public material1: eui.Group;
	public material2: eui.Group;
	public material3: eui.Group;
	public shouzhiGroup: eui.Group;
	public nextStep: eui.Button;
	public next: eui.Button;
	public prev: eui.Button;

	// 游戏
	public treeGroup: eui.Group;//树区域group
	public tree: z.tree2;

	public gameCount: number = 60;
	private answerTimers: any;
	public gameBj: eui.Image;
	public startCountDown: eui.Group;
	public startCountNum: eui.Group;
	public snailGroup: eui.Group;	//蜗牛

	public successImg: eui.Image;
	public errorImg: eui.Image;

	public answerGroup: eui.Group;
	public answerSubNum: number = 10;//游戏答题监听第几题
	public answerCountNum: eui.Label;	//答题倒计时
	public answerResult: number = 0;	//存储答案
	public greaterValue: number = 0;	//存储高分 
	public answerResultError: number = 0;//答错几道题
	public isBeforSubject: boolean = true;
	private isplayed: boolean = false;;
	public answerResultArr: Array<any> = []

	public answerLabel: eui.Label;
	public resultTipBtn: eui.Image;
	public answerTipGroup: eui.Group;
	public answerLabelTip: eui.Label;
	public clickSubject: eui.Group;
	public resultLabelGroup: eui.Group;

	//闯关成功
	public fractionGroup: eui.Group;
	public snailShow: eui.Image;
	public setUserName: eui.Image;
	public cradHeight: eui.Label;
	public cradSubNum: eui.Label;
	public cardSucccess: eui.Label;
	public cradAccuracy: eui.Label;
	public cardName: eui.Label;

	//时间到
	public clockGroup: eui.Group


	//动画
	public clock: dragonBones.EgretArmatureDisplay; //闹钟
	public shouzhi: dragonBones.EgretArmatureDisplay; //手指
	public clockAnimate = {
		take: "clock",			//接收返回值使用 可传可不传
		// dom: "keySetGroupAnimate",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "clock_ske_json",	//必传
		textureData1: "clock_tex_json",		//必传
		texture1: "clock_tex_png",			//必传
		name: "clock",								//必传
		animateName: "clock-end",								//必传
		count: 5									//必传
	};
	public snail: dragonBones.EgretArmatureDisplay; //蜗牛
	public snailAnimate = {
		take: "snail",			//接收返回值使用 可传可不传
		dom: "snailGroup",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "snail_ske_json",	//必传
		textureData1: "snail_tex_json",		//必传
		texture1: "snail_tex_png",			//必传
		name: "snail",								//必传
		count: -1									//必传
	};
	public shouzhiAnimate = {
		take: "shouzhi",			//接收返回值使用 可传可不传
		dom: "shouzhiGroup",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "shouzhi_ske_json",	//必传
		textureData1: "shouzhi_tex_json",		//必传
		texture1: "shouzhi_tex_png",			//必传
		name: "shouzhi",								//必传
		count: -1									//必传
	};
	public giddy: dragonBones.EgretArmatureDisplay; //眩晕
	public giddyAnimate = {
		take: "giddy",			//接收返回值使用 可传可不传
		dom: "snailGroup",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "giddy_ske_json",	//必传
		textureData1: "giddy_tex_json",		//必传
		texture1: "giddy_tex_png",			//必传
		name: "giddy",								//必传
		count: 3									//必传
	};
	public countDown: dragonBones.EgretArmatureDisplay; //倒计时321
	public countDownAnimate = {
		take: "countDown",			//接收返回值使用 可传可不传
		dom: "startCountNum",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "countdown_ske_json",	//必传
		textureData1: "countdown_tex_json",		//必传
		texture1: "countdown_tex_png",			//必传
		name: "countdown",								//必传
		count: 1									//必传
	};
	public snail_5: dragonBones.EgretArmatureDisplay; //-5秒
	public snail_5Animate = {
		take: "snail_5",			//接收返回值使用 可传可不传
		dom: "answerGroup",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "snail-5_ske_json",	//必传
		textureData1: "snail-5_tex_json",		//必传
		texture1: "snail-5_tex_png",			//必传
		name: "snail_5",								//必传
		count: 1									//必传
	};
	public clock_5: dragonBones.EgretArmatureDisplay; //-5秒
	public clock_5Animate = {
		take: "clock_5",			//接收返回值使用 可传可不传
		// dom: "startCountNum",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "clock-5_ske_json",	//必传
		textureData1: "clock-5_tex_json",		//必传
		texture1: "clock-5_tex_png",			//必传
		name: "clock_5",								//必传
		count: 1									//必传
	};
	public gameOver: dragonBones.EgretArmatureDisplay; //卡片
	public gameOverAnimate = {
		take: "gameOver",			//接收返回值使用 可传可不传
		// dom: "startCountNum",	//addChild的dom节点 不传默认 this.addChild
		dragonbonesData: "gameOver_ske_json",	//必传
		textureData1: "gameOver_tex_json",		//必传
		texture1: "gameOver_tex_png",			//必传
		name: "gameOver",								//必传
		count: 3									//必传
	};
	// 音乐
	public music_bj: egret.SoundChannel;
	public racTipMusic: egret.SoundChannel;
	public isMusic: boolean = true;

	public tq_bj: egret.Sound = RES.getRes("tq_bj_mp3");

	public constructor() {
		super();
		this.skinName = "IndexSkin";
	}

	protected partAdded(partName: string, instance: any): void {
		super.partAdded(partName, instance);
	}


	protected childrenCreated(): void {
		this.music.addEventListener(egret.TouchEvent.TOUCH_TAP, this.musicFun, this);
		this.reset.addEventListener(egret.TouchEvent.TOUCH_TAP, this.resetFun, this);
		this.subNum.addEventListener(Data.DATA, this.changNumber, this); //当数字发生改变时调用

		//教材
		this.material.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickMaterial, this); //教材
		eui.Watcher.watch(this, ["materialNum"], this.materialNumChange, this);
		this.nextStep.addEventListener(egret.TouchEvent.TOUCH_TAP, this.nextStepFun, this); //下一步
		eui.Watcher.watch(this, ["materialStepNum"], this.materialStepChange, this);

		this.next.addEventListener(egret.TouchEvent.TOUCH_TAP, this.nextFun, this); //下一题
		this.prev.addEventListener(egret.TouchEvent.TOUCH_TAP, this.prevFun, this); //上一题
		this.backing.addEventListener(egret.TouchEvent.TOUCH_TAP, () => { this.materialNum = 0 }, this); //返回
		//游戏
		this.game.addEventListener(egret.TouchEvent.TOUCH_TAP, this.startGame, this); //游戏
		this.resultTipBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.resultTipBtnFun, this); //提示按钮
		eui.Watcher.watch(this, ["answerSubNum"], this.answerSubNumFun, this);

		// this.resultLabelGroup.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickSubjectFun,this)
		this.clickSubject.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickSubjectFun, this); //选择答案
		this.setUserName.addEventListener(egret.TouchEvent.TOUCH_TAP, this.setUserNameBtnFun, this); //确定按钮 排行榜
		super.childrenCreated();

		// 开始按钮 等游戏实现后 解开注释使用
		// this.clickStart.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
		// 	this.endStart.visible = false;
		// 	this.start();
		// }, this);

		this.start()
	}
	// 开始游戏
	public start() {
		this.shouzhi.visible = false
		this.gameCount = 60;	//倒计时重置
		clearInterval(this.answerTimers)
		this.answerGroup.visible = false;	//隐藏答题框所有东西
		this.answerTipGroup.visible = false; //点击提示显示答题步骤

		this.startCountDown.visible = false;//隐藏倒计时321
		this.gameBj.visible = false; //隐藏游戏背景
		this.clockGroup.visible = false //闹钟时间的group
		this.fractionGroup.visible = false; //闯关成功
	}
	/***************教材*******************/
	//点击教材
	public clickMaterial() {
		console.log("点击教材");
		// var obj = { name: this.materialBj, transfrom: { x: 0 } };
		// this.tweenFun(obj).call(() => {
		this.materialBj.visible = true;
		this.prev.visible = false;
		this.next.visible = true;
		// this.nextStep.visible = true;
		// })
		this.materialStepNum = 1;
		this.materialNum = 1;

	}
	//监听教材数量
	public materialNumChange() {
		for (var i = 1; i <= 3; i++) {
			this["material" + i].x = 1920;
			// console.log("material" + i, this["material" + i].x)
			// console.log(this["material" + i].$children.length)
			for (let j = 2; j < this["material" + i].$children.length; j++) {
				this["material" + i].getChildAt(j).y = 1080;
				// console.log(this["material" + i].getChildAt(j).y)
			}
		}
		if (this.materialNum != 0) {
			var groupObj = this["material" + this.materialNum];
			var obj = { name: groupObj, transfrom: { x: 0 } };
			this.tweenFun(obj).call(() => {
				this.next.enabled = true;
				this.prev.enabled = true;
			})
		} else {
			// var obj2 = { name: this.materialBj, transfrom: { x:1920 } };
			// this.tweenFun(obj2).call(() => {
			// this.materialBj.x = 1920;
			this.materialBj.visible = false;
			// this.next.visible = false;
			// this.prev.visible = false;
			// this.nextStep.visible = false;
			// })
		}
	}
	// 点击下一步
	public nextStepFun() {
		console.log("下一步")
		this.nextStep.enabled = false;

		var groupObj = this["material" + this.materialNum].$children.length - 1;
		if (groupObj > this.materialStepNum) {
			this.materialStepNum++;
		}
	}
	//监听下一步
	public materialStepChange() {
		console.log("监听下一步");
		if (this.materialStepNum != 0 && this.materialStepNum != 1) {
			var groupObj = this["material" + this.materialNum].$children;

			var index = groupObj[this.materialStepNum];

			var y = groupObj[this.materialStepNum - 1].y + index.height + 70;

			var obj = { name: index, transfrom: { y: y } };
			this.tweenFun(obj).call(() => {
				this.nextStep.enabled = true;
			})
		} else {
			this.nextStep.enabled = true;
		}
	}
	//下一题
	public nextFun() {
		this.next.enabled = false;

		this.materialStepNum = 1
		if (this.materialNum >= 2) {
			this.next.visible = false;
			this.materialNum++
		} else {
			this.prev.visible = true;
			this.materialNum++
		}

	}
	//上一题
	public prevFun() {
		this.prev.enabled = false;
		this.materialStepNum = 1

		if (this.materialNum <= 2) {
			this.prev.visible = false;
			this.materialNum--
		} else {
			this.next.visible = true;
			this.materialNum--
		}
	}
	//缓动动画
	public tweenFun(obj) {
		return egret.Tween.get(obj.name).to(obj.transfrom, this.times);
	}
	//监听数字函数
	public changNumber(e: egret.Event) {
		console.log(e.target.value)
		console.log(this.subNum.value)
	}
	/*******************游戏*************************/
	public startGame() {
		this.gameCount = 60;	//倒计时重置
		this.gameBj.visible = true;			//显示背景图
		this.answerGroup.visible = false;	//隐藏答题框所有东西
		this.answerTipGroup.visible = false; //点击提示显示答题步骤
		this.fractionGroup.visible = false; //闯关成功

		this.startGameCountDown()
		// this.sessionStorageFun() 	//存储数据

		//凯哥哥
		this.tree = new z.tree2();
		this.treeGroup.addChild(this.tree)
		this.tree.width = this.treeGroup.width
		this.tree.height = this.treeGroup.height;
		this.shouzhi = this.animationFun(this.shouzhiAnimate);

		// this.shouzhi.armature.animation.play("shouzhi")
		this.shouzhi.x = 1220;
		this.shouzhi.y = 376;
		this.shouzhi.visible = false;

	}
	//开始倒计时3秒
	public startGameCountDown() {
		this.startCountDown.visible = true;
		this.countDown = this.animationFun(this.countDownAnimate)

		if (this.imgFilterArr.length >= 1) {
			this.imgFilterArr[0].filters = null;
		}
		// this.startCountDown.visible = false;
		// this.answerCountDown();	//答题倒计时
		// this.answerSubNum = 1;	//第一题

	}
	//答题倒计时
	public answerCountDown() {
		this.answerGroup.visible = true;
		this.answerCountNum.text = this.gameCount + "";

		this.answerTimers = setInterval(() => {
			var count = parseInt(this.answerCountNum.text)
			if (count <= 1) {
				this.answerCountNum.text = "0"
				clearInterval(this.answerTimers);
				// this.answerGroup.visible = false;	//隐藏答题闹钟及面板
				this.clockGroup.visible = true;
				this.clock = this.animationFun(this.clockAnimate)
				this.snail.animation.stop()
				this.clock.x = 400;
				// this.sessionStorageFun() 	//存储数据
			} else {
				this.gameCount--;
				if (this.gameCount <= 0) {
					this.answerCountNum.text = "0";
				} else {
					this.answerCountNum.text = this.gameCount + "";
				}

			}
		}, 1000)
	}
	//生成题目
	public answerSubject() {
		let sum: number = 0;
		if (this.answerSubNum < 10) {
			let num1 = Math.floor(Math.random() * 161 + 20);
			let num2 = Math.floor(Math.random() * 78 + 20);
			let num3 = 0;
			let mark1 = Math.random() > 0.5 ? "+" : "-"; //随机生成“+”，“-” 用于计算中间数
			let mark2 = "+";

			if (num1 > 100) {
				num3 = num1 - 100;
				mark2 = "-"
			} else {
				num3 = 100 - num1;
				mark2 = "+";
			}
			sum = eval(num1 + mark1 + num2 + mark2 + num3);
			let tip = "= ( " + num1 + " " + mark2 + " " + num3 + " ) " + mark1 + " " + num2;
			this.answerLabel.text = num1 + " " + mark1 + " " + num2 + " " + mark2 + " " + num3 + " = " + "?"	//设置题目
			this.answerLabelTip.text = tip
			this.resultLabelGroup;

			// console.log("题目：" + num1 + mark1 + num2 + mark2 + num3 + "=" + sum)
			// console.log("提示：" + tip)
		} else if (this.answerSubNum < 40) {
			let randomNum = Math.floor(Math.random() * 9 + 1) * 100;
			let num1 = 0;
			let num2 = Math.floor(Math.random() * 378 + 20);
			let num3 = Math.floor(Math.random() * 3 + 1);
			let mark1 = "+"
			let mark2 = Math.random() > 0.5 ? "+" : "-";	//随机生成“+”，“-” 用于计算随机生成的1~3的数
			let tip = "";
			//如果随机数大于num2的话 等式应该使用“+”号 在修改num2的值在一定范围
			if (randomNum >= num2) {
				num2 = Math.floor(Math.random() * 112 + 20);
				mark1 = "+";
				num1 = eval(randomNum + mark2 + num3);
				tip = "= ( " + randomNum + " " + mark1 + " " + num2 + " " + " ) " + mark2 + " " + num3;
			} else {	//如果随机数小于num2的话 等式应该使用“-”号 在修改num1的值一定大于num2的值 设置num2的值应该在一定范围内
				let ran = Math.floor(Math.random() * 3 + 1) * 100;
				mark1 = "-"
				num1 = ran + Math.floor(Math.random() * 178);
				num2 = eval(ran + mark1 + num3);
				tip = "= " + num1 + " " + mark2 + " ( " + ran + " " + mark1 + " " + num3 + " )";
			}
			sum = eval(num1 + mark1 + num2);
			this.answerLabel.text = num1 + " " + mark1 + " " + num2 + " " + " = " + "?"
			this.answerLabelTip.text = tip
			// console.log("题目：" + num1 + mark1 + num2 + "=" + sum)
			// console.log("提示：" + tip);
		}
		//添加答案
		var resultPosition = Math.floor(Math.random() * 4);

		for (let i = 0; i < 4; i++) {

			if (i == resultPosition) {
				this.answerResultArr[i] = sum;
				this.answerResult = resultPosition;
			} else {
				this.answerResultArr[i] = this.randomResult(sum)
			}
		}
		//遍历显示答案
		var labelGroup: any = this.resultLabelGroup.$children;
		this.answerResultArr.map((item, index) => {
			labelGroup[index].text = item + ""
		})
		// console.log(this.answerResultArr)
	}
	//生成随机数答案
	public randomResult(sum) {
		for (; ;) {
			let mark = Math.random() > 0.5 ? "+" : "-";
			let ran = Math.floor(Math.random() * 5 + 1);
			let result = eval(sum + mark + ran);
			if (this.answerResultArr.indexOf(result) == -1) {
				return result;
			}
		}
	}
	//监听题目变化
	public answerSubNumFun() {
		this.answerTipGroup.visible = false; //点击提示显示答题步骤
		this.resultTipBtn.source = "woniukuaipa_13_png"	//切换提示
		this.answerSubject()

	}
	//提示按钮
	public resultTipBtnFun() {
		if (this.isplayed == false) {
			this.shouzhi.y = 686
			if (this.answerResult == 0) {
				this.shouzhi.x = 600
			} else if (this.answerResult == 1) {
				this.shouzhi.x = 818
			} else if (this.answerResult == 2) {
				this.shouzhi.x = 1048
			} else if (this.answerResult == 3) {
				this.shouzhi.x = 1280
			}
		}
		if (this.answerTipGroup.visible) {
			this.answerTipGroup.visible = false; //点击提示显示答题步骤
			this.resultTipBtn.source = "woniukuaipa_13_png"
		} else {
			this.answerTipGroup.visible = true; //点击提示显示答题步骤
			this.resultTipBtn.source = "woniukuaipa_14_png"
		}

	}
	//选择答案 
	public clickSubjectFun(e: egret.TouchEvent) {
		if (e.target.name != "group") {

			this.clickSubject.touchChildren = false;	//禁止点击
			var index = this.clickSubject.$children.indexOf(e.target);
			console.log("选择答案：" + index, "正确答案:" + this.answerResult)
			if (index == this.answerResult) {
				// this.answerSubNum++
				this.tweenIsError(this.successImg, e.target)
				this.filtersFun(e.target, 0x67F5FA)
				// this.tree.fastgo();
				// this.snail.animation.play("snail_up", 2);
				console.log("回答正确")
				this.shouzhi.visible = false;
				this.isplayed = true;
			} else {
				this.tweenIsError(this.errorImg, e.target)
				this.filtersFun(e.target, 0xF55D08)
				//减5秒
				if (this.gameCount > 5) {
					this.gameCount = this.gameCount - 5
				} else {
					this.gameCount = 0;
				}
				if (this.isBeforSubject) {
					this.answerResultError++;
					this.isBeforSubject = false;
				}
				// this.clock_5 = this.animationFun(this.clock_5Animate)
				// this.snail.animation.stop()
				// this.giddy = this.animationFun(this.giddyAnimate);
				// this.tree.err();
				console.log("回答错误")
			}
		}
	}
	//小球移动
	public tweenIsError(item: any, target: any) {
		item.visible = true;
		item.x = target.x + target.parent.x;
		item.y = target.y + target.parent.y;
		egret.Tween.get(item).to({ x: this.snailGroup.x, y: this.snailGroup.y }, 500).call(() => {
			item.visible = false;
			if (item.source == "successImg_png") {
				this.tree.fastgo();
				this.snail.animation.play("snail_up", 2);

				this.clickSubject.touchChildren = true;	///***********************启用点击
				this.answerSubNum++		///***************************************换题
				this.isBeforSubject = true;
			} else {
				this.snail.animation.stop()

				this.snail_5 = this.animationFun(this.snail_5Animate);
				this.snail_5.scaleX = 0.5
				this.snail_5.scaleY = 0.5
				this.snail_5.x = 10
				this.snail_5.y = 35

				this.giddy = this.animationFun(this.giddyAnimate);
				this.tree.err();
			}
		})
	}
	//数据存储
	public sessionStorageFun() {
		var obj = { height: this.greaterValue, userName: this.cardName.text }
		if (sessionStorage.getItem("data") == null) {
			let data = [obj]
			console.log(data)
			sessionStorage.setItem("data", JSON.stringify(data))
		} else {
			console.log(sessionStorage.getItem("data"))
			let data = JSON.parse(sessionStorage.getItem("data"));
			data.push(obj)
			sessionStorage.setItem("data", JSON.stringify(data))
		}
	}
	public setUserNameBtnFun() {
		this.sessionStorageFun();
		this.startGame()
	}
	//开始 暂停 背景音乐
	public musicFun() {
		if (this.isMusic) {
			this.music_bj.stop()
			this.isMusic = false;
			this.music.source = "music_close_png"
		} else {
			this.music_bj = this.tq_bj.play(0, -1)
			this.isMusic = true;
			this.music.source = "music_png"
		}
	}
	//重置
	public resetFun() {
		window.location.reload();
	}
	//调用移除上一个音乐 并播放本次音乐
	public playMusic(name, count = 1) {
		if (this.racTipMusic) {
			this.racTipMusic.stop()
		}
		this.racTipMusic = this[name].play(0, count);
		return this.racTipMusic;
	}
	// 动画
	public animationFun(dbObj) {
		//进来先移除动画在播放  避免动画叠加
		if (this[dbObj.take]) {
			if (this[dbObj.take].parent) {
				dbObj.dom ? this[dbObj.dom].removeChild(this[dbObj.take]) : this.removeChild(this[dbObj.take]);
			}
		}
		//添加文件
		let dragonbonesData = RES.getRes(dbObj.dragonbonesData);
		let textureData = RES.getRes(dbObj.textureData1);
		let texture = RES.getRes(dbObj.texture1);
		// 创建动画工厂
		let egretFactoryA = new dragonBones.EgretFactory();
		egretFactoryA.parseDragonBonesData(dragonbonesData);
		egretFactoryA.parseTextureAtlasData(textureData, texture);
		//创建动画
		let armature: dragonBones.EgretArmatureDisplay = egretFactoryA.buildArmatureDisplay(dbObj.name);
		//添加到舞台
		dbObj.dom ? this[dbObj.dom].addChild(armature) : this.addChild(armature);

		//播放动画
		armature.animation.gotoAndPlayByFrame(dbObj.animateName ? dbObj.animateName : dbObj.name, 1, dbObj.count);
		//监听帧
		armature.addEventListener(dragonBones.EventObject.FRAME_EVENT, (e) => {
			// console.log(e.frameLabel)
		}, this)
		//动画播放完成
		armature.addEventListener(dragonBones.EventObject.COMPLETE, () => {
			if (armature.parent) {	// 播放完成移除动画
				dbObj.dom ? this[dbObj.dom].removeChild(armature) : this.removeChild(armature);
			}
			if (dbObj.name == "countdown") {	//倒计时321
				this.startCountDown.visible = false;
				this.answerCountDown();
				this.answerSubNum = 1;	//第一题
				this.answerResultError = 0;	//错误归零
				this.tree.auto();	//开始动 树
				if (this.isplayed == false) {
					this.shouzhi.visible = true;
				}
				this.snail = this.animationFun(this.snailAnimate);
				this.snail.scaleX = 0.5;
				this.snail.scaleY = 0.5;
			} else if (dbObj.name == "clock") {
				this.greaterValue = this.tree.stop();
				console.log(this.tree.stop())
				//设置记录
				this.cradHeight.text = this.greaterValue + "";
				this.cradSubNum.text = this.isBeforSubject ? this.answerSubNum - 1 + "" : this.answerSubNum + "";
				this.cardSucccess.text = this.answerResultError + " ";
				this.cradAccuracy.text = (100 - parseFloat((this.answerResultError / this.answerSubNum).toFixed(2)) * 100) + "%";

				if (sessionStorage.getItem("data") == null) {
					this.cardName.text = "学生1"
				} else {
					console.log(sessionStorage.getItem("data").length)
					this.cardName.text = "学生" + JSON.parse(sessionStorage.getItem("data")).length
				}
				this.answerGroup.visible = false;
				this.clockGroup.visible = false;
				this.fractionGroup.visible = true; //闯关成功面板
				console.log("弹出答题版")
			} else if (dbObj.name == "giddy") {
				this.clickSubject.touchChildren = true;	//启用点击
				this.snail.animation.play("snail", -1)
				this.tree.ok();	//恢复动画
			} else if (dbObj.name == "snail") {
				this.imgFilterArr[0].filters = null;	//取消滤镜效果
				//调用蜗牛走的动画
				this.snail = this.animationFun(this.snailAnimate);
				this.snail.scaleX = 0.5;
				this.snail.scaleY = 0.5;
			}
		}, this)

		return armature;
	}
	//滤镜
	public filtersFun(img, isError) {
		if (this.imgFilterArr.length >= 1) {
			this.imgFilterArr[0].filters = null;
			this.imgFilterArr.splice(0, 1)
		}
		var distance: number = 0;           /// 阴影的偏移距离，以像素为单位
		var angle: number = 45;              /// 阴影的角度，0 到 360 度
		var color: number = isError;        /// 阴影的颜色，不包含透明度
		var alpha: number = 0.7;             /// 光晕的颜色透明度，是对 color 参数的透明度设定
		var blurX: number = 35;              /// 水平模糊量。有效值为 0 到 255.0（浮点）
		var blurY: number = 35;              /// 垂直模糊量。有效值为 0 到 255.0（浮点）
		var strength: number = 5;                /// 压印的强度，值越大，压印的颜色越深，而且阴影与背景之间的对比度也越强。有效值为 0 到 255。暂未实现
		var quality: number = egret.BitmapFilterQuality.LOW;              /// 应用滤镜的次数，暂无实现
		var inner: boolean = true;            /// 指定发光是否为内侧发光
		var knockout: boolean = false;            /// 指定对象是否具有挖空效果
		var dropShadowFilter: egret.DropShadowFilter = new egret.DropShadowFilter(distance, angle, color, alpha, blurX, blurY,
			strength, quality, inner, knockout);
		img.filters = [dropShadowFilter];
		this.imgFilterArr.push(img);
	}
}